<template>
		<view class="dmm-container dmm-container-grey">
			<image :src="statusIcon" mode=""></image>
			
			<view class="" v-if="agentInfo.agentStatus === '4'">
				<text class="text text-content">抱歉，您的信息未能审核通过</text>
				<text class="text text-content">未通过原因：{{agentInfo.auditFailReason}}</text>
			</view>
			
			<view class="" v-if="agentInfo.agentStatus === '2'">
				<text class="text text-content">您的信息正在审核中</text>
				<text class="text text-content">请耐心等待审核！</text>
			</view>
			
			<u-button @click="uniHistory.push('/pages/auth/auth4')" v-if="agentInfo.agentStatus === '4'" type="primary" text="重新编辑"></u-button>
			<u-button @click="goBack" v-if="agentInfo.agentStatus === '2'" type="primary" text="返回首页"></u-button>
		</view>
</template>

<script>
	import {mapState} from 'vuex'
	
	export default {
		data: function() {
			return {
				fromAuth: true,
			}
		},
		
		computed: {
			...mapState('home', ['agentInfo']),
			statusIcon: function() {
				const iconEnum = {
					2: '/static/imgs/icon_authing.png',
					4: '/static/imgs/icon_auth_fail.png'
				}
				return iconEnum[this.agentInfo.agentStatus] || ''
			}
		},
		
		methods: {
			goBack() {
				if (this.fromAuth) {
					this.uniHistory.back(5)
				} else {
					this.uniHistory.goBack()
				}
			}
		},
		
		created() {
			if (this.agentInfo.agentStatus === '2') uni.setNavigationBarTitle({title: '审核中'})
			if (this.agentInfo.agentStatus === '4') uni.setNavigationBarTitle({title: '审核失败'})
		},
		
		onLoad(options) {
			const {fromAuth} = options
			
			this.fromAuth = fromAuth === 'true'
		}
	}
</script>

<style lang="scss">
	.dmm-container {
		display: flex;
		flex-direction: column;
		align-items: center;
		padding-top: 163rpx;
		
		image {
			height: 120rpx;
			width: 120rpx;
			margin-bottom: 36rpx;
		}
		
		.text {
			display: block;
			text-align: center;
			margin-bottom: 10rpx;
		}
		
		.u-button {
			width: 660rpx !important;
			margin: 114rpx 45rpx;
		}
	}
</style>
